<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <#assign base=request.contextPath  />
    <base id="basePath" href="${base}">
    <link rel="stylesheet" href="${base}/css/demo.css" type="text/css">
    <link rel="stylesheet" href="${base}/css/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.exedit.js"></script>
    <link rel="stylesheet" href="${base}/js/layui/css/layui.css">
    <script src="${base}/js/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <style type="text/css">
        form{
            padding:20px;
        }
        .layui-btn-radius{
            border-radius: 5px;
        }
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title">
    <legend>周报</legend>
</fieldset>
<div class="layui-tab" lay-filter="test">
    <ul class="layui-tab-title">
        <li class="layui-this" lay-id="11">写周报</li>
        <li lay-id="22" onclick="aaa(null,null,null)">看周报</li>
    </ul>
    <script>
        function aaa(sendName,logContent,test6){
            $.ajax({
                type:"POST",
                url:"${base}/monthlyReport/selectMonthlyReport",
                data:{"sendName":sendName,"logContent":logContent,"test6":test6},
                success:function(data){
                    //alert(test6)
                    //alert(data)
                    var htm="";
                    if(data.length>0){

                        for(var i=0;i<data.length;i++){
                            if(data[i].complete==null||data[i].complete==""||data[i].complete=="null"){
                                data[i].complete="";
                            }
                            if(data[i].summary==null||data[i].summary==""||data[i].summary=="null"){
                                data[i].summary="";
                            }
                            if(data[i].workPlan==null||data[i].workPlan==""||data[i].workPlan=="null"){
                                data[i].workPlan="";
                            }
                            if(data[i].coordinate==null||data[i].coordinate==""||data[i].coordinate=="null"){
                                data[i].coordinate="";
                            }
                            if(data[i].remarks==null||data[i].remarks==""||data[i].remarks=="null"){
                                data[i].remarks="";
                            }


                            if (data[i].name != '' && data[i].name!=null) {
                                htm +='<div id="day" class="layui-col-xs12 layui-col-sm6 layui-col-md4"style="width:80%;padding:20px;">'+
                                        '<div class="layui-collapse" >'+
                                        '<div class="layui-colla-item">'+
                                        '<h2 class="layui-colla-title">姓名:'+data[i].name+'<i class="layui-icon layui-icon-delete" style="font-size:30px;float:right;" href="javascript:void(0)"  onclick="onDelete(' + "'" + data[i].id + "'"+')"  ></i></h2>'+
                                        '<div class="layui-colla-content layui-show">'+
                                        '<ul class="layui-timeline max-auto">'+
                                        '<li class="layui-timeline-item">'+
                                        '<i class="layui-icon layui-timeline-axis">&#xe63f;</i>'+
                                        '<div class="layui-timeline-content layui-text">'+
                                        '<h3 class="layui-timeline-title"><span>'+DateFormat(data[i].createTime)+'</span></h3>'+
                                        '<ul>'+
                                        '<li>本周完成工作:'+data[i].complete+'</li>'+
                                        '<li>本周总结:'+data[i].summary+'</li>'+
                                        '<li>下周工作计划:'+data[i].workPlan+'</li>'+
                                        '<li>需协调工作:'+data[i].coordinate+'</li>'+
                                        '<li>备注:'+data[i].remarks+'</li>'+
                                        '</ul>'+
                                        '</div></li></ul></div></div></div></div>'
                            }

                        }


                    }
                    $("#day").html(htm)
                }
            });
        }

    </script>

    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" id="name" autocomplete="off" placeholder="请输入姓名" class="layui-input isNull" lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">本周完成工作</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" id="complete" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">本周总结</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" id="summary" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">下周工作计划</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" id="workPlan" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">需协调工作</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" id="coordinate" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" id="remarks" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-input-block" style="float: right;">
                        <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" onclick="onSubmit()" style="background-color: #0092EF;">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
                    </div>
            </form>
        </div>
    </div>
    <div class="layui-tab-item">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">发送人</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" id="sendName" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">日期范围</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="test6" placeholder="至">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">日志内容</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name"  id="logContent" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button"   onclick="sech()" style="background-color: #0092EF;">开始搜索</button>
                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
                </div>
            </div>
        </form>
        <div id="day">


        </div>
    </div>
</div>
</div>
<script>
    layui.use(['element', 'form', 'table', 'layer',  'laydate'], function () {
        var form = layui.form;
        var table = layui.table;
        var layer = layui.layer;
        var vipTab = layui.vip_tab;
        var element = layui.element;
        var layedit = layui.layedit;
        var laydate = layui.laydate;
        var  $ = layui.jquery;

        laydate.render({
            elem: '#test6'
            ,range: true
        });

        var active = {
            tabChange: function(){
                //切换到指定Tab项
                element.tabChange('demo', '22'); //切换到：用户管理
            }
        };

        $('.site-demo-active').on('click', function(){
            var othis = $(this), type = othis.data('type');
            active[type] ? active[type].call(this, othis) : '';
        });
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);

        element.on('tab(test)', function(elem){
            location.hash = 'test='+ $(this).attr('lay-id');
        });

    });


    //提交
    function onSubmit(){
        if(!isNull()){
            return;
        }
        var jsonData = {};
        //姓名
        jsonData.name = $("#name").val();
        //本周完成工作
        jsonData.complete = $("#complete").val();
        //本周总结
        jsonData.summary = $("#summary").val();
        //下周工作计划
        jsonData.workPlan = $("#workPlan").val();
        //需协调工作
        jsonData.coordinate = $("#coordinate").val();
        //备注
        jsonData.remarks = $("#remarks").val();

        $.ajax({
            type:"POST",
            url:"${base}/monthlyReport/insertMonthly",
            data:{"param":JSON.stringify(jsonData)},
            success:function(data){

                layer.msg("添加成功");

                setTimeout(function(){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                },800)


                //姓名
                jsonData.name = $("#name").val("");
                //本周完成工作
                jsonData.complete = $("#complete").val("");
                //本周总结
                jsonData.summary = $("#summary").val("");
                //下周工作计划
                jsonData.workPlan = $("#workPlan").val("");
                //需协调工作
                jsonData.coordinate = $("#coordinate").val("");
                //备注
                jsonData.remarks = $("#remarks").val("");

                var table = layui.table;
                //表刷新方法
                table.reload('testReload', {
                    url: '${base}/monthlyReport/selectMonthly'
                    ,where: {} //设定异步数据接口的额外参数
                    //,height: 300
                });
            }
        });



    }

    //搜索

    function sech(){
        aaa($("#sendName").val(),$("#logContent").val(),$("#test6").val());
    }





    //删除
    function onDelete(id){

//提示是否删除这条数据
//data里边的customerId是需要和实体类里边的id是一样的,不然是传不过来参数的
        layer.confirm('真的要删除吗?',function(index){
            $.ajax({
                type:"POST",
                url:"${base}/monthlyReport/deleteMonth",
                data:{"id":id},
                sync:false,
                success:function(data){

                    aaa(null,null,null);
                    //关闭删除是否删除的提示框
                    layer.close(index);
                }
            });
        });
    }






</script>
</body>
</html>